import { getAlertJobInfo } from '../services/alarm-job-controller';

export default {
  namespace: 'JobDetailModel',

  state: {
    name: '...',
    jobInfo: {},
  },

  effects: {
    *getAlertJobInfo({ payload }, { call, put }) {
      const { name } = payload;
      // 请求数据
      const jobInfo = yield call(getAlertJobInfo, name);
      if (!jobInfo) return;
      // 保存数据
      yield put({ type: 'save', payload: { name, jobInfo } });
    },
  },

  reducers: {
    save(state, { payload }) {
      return { ...state, ...payload };
    },
  },
};
